package com.job.moudle2.task3;

import java.math.BigDecimal;

/**
 * 手机卡类
 * 成员变量：类型，卡号，用户名，密码，账户余额，通话时长，上网流量
 * 成员方法：显示卡号+用户名+当前余额
 */
public class SIMCard {

    /**
     * 卡类型
     */
    private CardType cardType;
    private String cardNo;
    private String userID;
    private String userPassword;
    private BigDecimal accountBalance;
    private int talkTimes;
    private Double netData;

    public SIMCard() {
    }

    public SIMCard(String userID, String userPasswd) {
        this.userID = userID;
        this.userPassword = userPasswd;
        System.out.println("请选择卡片类型，完善其他信息");
    }

    public CardType getCardType() {
        return cardType;
    }

    public void setCardType(CardType cardType) {
        this.cardType = cardType;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPasswd) {
        this.userPassword = userPasswd;
    }

    public BigDecimal getAccountBalance() {
        return accountBalance;
    }

    public void setAccountBalance(BigDecimal accountBalance) {
        this.accountBalance = accountBalance;
    }

    public int getTalkTimes() {
        return talkTimes;
    }

    public void setTalkTimes(int talkTimes) {
        this.talkTimes = talkTimes;
    }

    public Double getNetData() {
        return netData;
    }

    public void setNetData(Double netData) {
        this.netData = netData;
    }

    public void show() {
        System.out.println("卡号：" + cardNo + ", 用户名：" + userID + "， 当前余额：" + accountBalance);
    }

    /**
     * 用户开卡完成后，需要预扣费的模拟
     */
    public void preChargeBack(SetMeal... setMeals) {
        UserConsumption userConsumption = UserConsumption.getInstance();
        for(SetMeal setMeal: setMeals) {
            accountBalance = accountBalance.subtract(setMeal.getMonthlyRates());
            userConsumption.addMonthlyRates(setMeal.getMonthlyRates());
        }
    }
}
